﻿#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
int main()
{
	string str = "XYZ";
	cout << "str[0]=" << (int)str[0] << endl;
	cout << "str[1]=" << (int)str[1] << endl;
	cout << "str[2]=" << (int)str[2] << endl;
	cout << "str[3]=" << (int)str[3] << endl;
	char name[11];//没有初始化，里面是垃圾值，会直到找到0才结束(错误写法)
	memset(name, 0, sizeof(name));//将字符串清空
	cout << "name=" << name << endl;
	strcpy(name, "hello");
	cout << "name=" << name << endl;
	int i = strlen("hello7777");
	cout << "i=" << i << endl;
	char name1[11] = "hello";
	char name2[] = { "hello" };
	char name3[11] = { "hello" };
	char name4[11]{ "hello" }; //c++11标准
	char name5[11] = { 0 }; //清空字符串，全部元素初始化为0
}

